<?php

namespace app\common\validate;

use think\Validate;

class Parents extends Validate
{
    protected $regex = ['mobile' => '^1\d{10}$'];

    /**
     * 验证规则
     */
    protected $rule = [
        'number'            => 'require|unique:Parents,number',
        'mobile'            => 'require|mobile|unique:Parents,mobile',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'mobile.mobile' => '手机号格式错误'
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name', 'mobile'],
        'edit' => ['name' => 'require|unique:Parents,name^id', 'mobile' => 'require|mobile|unique:Parents,mobile^id']
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'name' => __('名称'),
            'mobile' => __('手机号'),
        ];
        parent::__construct($rules, $message, $field);
    }

}
